<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>centos 安装 配置 使用 | 学习笔记</title><meta name="author" content="lzoxun"><meta name="copyright" content="lzoxun"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="安装VMware 7 iso 选择语言 &#x3D;&gt; 选择安装模式等 &#x3D;&gt; 开始安装 &#x3D;&gt; 设置 root 密码 配置网络配置 vim &#x2F;etc&#x2F;sysconfig&#x2F;network-scripts&#x2F;ifcfg-enp7s0（或 ifcfg-ens33）  将ONBOOT&#x3D;no改为yes BOOTPROTO  stati">
<meta property="og:type" content="article">
<meta property="og:title" content="centos 安装 配置 使用">
<meta property="og:url" content="http://example.com/2023/07/22/linux/linux-centos/index.html">
<meta property="og:site_name" content="学习笔记">
<meta property="og:description" content="安装VMware 7 iso 选择语言 &#x3D;&gt; 选择安装模式等 &#x3D;&gt; 开始安装 &#x3D;&gt; 设置 root 密码 配置网络配置 vim &#x2F;etc&#x2F;sysconfig&#x2F;network-scripts&#x2F;ifcfg-enp7s0（或 ifcfg-ens33）  将ONBOOT&#x3D;no改为yes BOOTPROTO  stati">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png">
<meta property="article:published_time" content="2023-07-22T07:14:09.679Z">
<meta property="article:modified_time" content="2023-07-22T07:14:09.679Z">
<meta property="article:author" content="lzoxun">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2023/07/22/linux/linux-centos/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":true,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'centos 安装 配置 使用',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-22 15:14:09'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="学习笔记"><span class="site-name">学习笔记</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">centos 安装 配置 使用</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-22T07:14:09.679Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-22T07:14:09.679Z" title="更新于 2023-07-22 15:14:09">2023-07-22</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="centos 安装 配置 使用"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><p><a target="_blank" rel="noopener" href="https://www.vmware.com/cn/products/workstation-pro/workstation-pro-evaluation.html">VMware</a></p>
<p><a target="_blank" rel="noopener" href="http://mirrors.aliyun.com/centos/7/isos/x86_64/">7 iso</a></p>
<p>选择语言 &#x3D;&gt; 选择安装模式等 &#x3D;&gt; 开始安装 &#x3D;&gt; 设置 root 密码</p>
<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><h3 id="网络配置"><a href="#网络配置" class="headerlink" title="网络配置"></a>网络配置</h3><blockquote>
<p>vim &#x2F;etc&#x2F;sysconfig&#x2F;network-scripts&#x2F;ifcfg-enp7s0（或 ifcfg-ens33）</p>
</blockquote>
<p>将<code>ONBOOT=no</code>改为<code>yes</code></p>
<p><strong>BOOTPROTO</strong></p>
<ul>
<li><strong>static 静态分配 ip</strong></li>
<li><strong>bootp bootp 协议</strong></li>
<li><strong>dhcp DHCP 协议</strong></li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将BOOTPROTO=dhcp 改为 BOOTPROTO=static 就能静态分配IP</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">IPADDR=192.168.203.128  <span class="comment"># ip地址</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">NETMASK=255.255.255.0   <span class="comment"># 子网掩码</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">GATEWAY=192.168.203.2   <span class="comment"># 网关（最后不能.1）</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">DNS1=8.8.8.8    <span class="comment"># DNS</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">重启网络服务</span></span><br><span class="line">systemctl restart network</span><br></pre></td></tr></table></figure>

<p>编辑&#x2F;虚拟网络设置</p>
<p><img src= "" data-lazy-src="D:\lzo-project\lzo-docs-blog\static\img\2023-07-06_083543.jpg"></p>
<p><img src= "" data-lazy-src="D:\lzo-project\lzo-docs-blog\static\img\2023-07-06_083630.jpg"></p>
<h3 id="配置-yum-dnf"><a href="#配置-yum-dnf" class="headerlink" title="配置 yum &#x2F; dnf"></a>配置 yum &#x2F; dnf</h3><blockquote>
<p>RPM 软件包管理器，配置一些 yum 源</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">cd</span> /etc/yum.repos.d/ 备份、删除默认yum源</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">阿里云 yum 源</span></span><br><span class="line">wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">网易源</span></span><br><span class="line">wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">中科大</span></span><br><span class="line">wget -O /etc/yum.repos.d/CentOS-Base.repo &#x27;https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3&#x27;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">epel yum 源</span></span><br><span class="line">wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo (yum install epel-release)</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">重新建立缓存</span></span><br><span class="line">yum clean all</span><br><span class="line">yum makecache</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">使用</span></span><br><span class="line">yum install/remove pack-name</span><br></pre></td></tr></table></figure>

<blockquote>
<p>dnf <a target="_blank" rel="noopener" href="https://wangchujiang.com/linux-command/c/dnf.html">文档</a> <a target="_blank" rel="noopener" href="http://mirrors.aliyun.com/repo/">repo</a></p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">阿里云 源列表</span></span><br><span class="line">http://mirrors.aliyun.com/repo/</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装</span></span><br><span class="line">yum install dnf</span><br><span class="line">dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y</span><br><span class="line">dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">测试状态</span></span><br><span class="line">dnf repolist epel</span><br><span class="line">dnf repolist epel -v</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">建立元数据缓存</span></span><br><span class="line">dnf makecache</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">dnf 扩展工具</span></span><br><span class="line">dnf install dnf-plugins-core  # 就能使用 dnf copr</span><br><span class="line"></span><br><span class="line">epel的全称叫 Extra Packages for Enterprise Linux 。epel是由 Fedora 社区打造，为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目</span><br><span class="line">epel相当于一个第三方源。为什么需要 epel？因为 CentOS 官方源包含的大多数的库都是比较旧的。并且很多流行的库也不存在。当然这样做也是无可厚非的，毕竟服务器版本安全稳定是重点。</span><br></pre></td></tr></table></figure>

<h3 id="配置-git"><a href="#配置-git" class="headerlink" title="配置 git"></a>配置 git</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">如果版本太低</span></span><br><span class="line">yum remove git</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">跟新 rpm</span></span><br><span class="line">rpm -ivh http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装</span></span><br><span class="line">yum install</span><br></pre></td></tr></table></figure>

<h3 id="配置-nginx"><a href="#配置-nginx" class="headerlink" title="配置 nginx"></a>配置 nginx</h3><h3 id="配置-zsh"><a href="#配置-zsh" class="headerlink" title="配置 zsh"></a>配置 zsh</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">yum install zsh</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">chsh -s /bin/zsh 切换shell到zsh，重启，设置~/.zshrc</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">echo</span> <span class="variable">$SHELL</span> 查看当前使用的shell</span></span><br></pre></td></tr></table></figure>

<h3 id="配置-ssh"><a href="#配置-ssh" class="headerlink" title="配置 ssh"></a>配置 ssh</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">两个主机都生成公钥私钥</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">连接主机 `ssh-copy-id -i ./id_rsa.pub root@114.115.212.xxx` 向目标主机114 上传公钥</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">ssh root@xxx.xxx.xxx.xx  测试、连接远程</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">win 连 linux 可能需要在git bash上操作</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">远程主机直接将客户端的公钥加入 ~/.ssh/authorized_keys 文件中</span></span><br></pre></td></tr></table></figure>

<h3 id="配置-nvm"><a href="#配置-nvm" class="headerlink" title="配置 nvm"></a>配置 nvm</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">git</span></span><br><span class="line"> wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash</span><br><span class="line"> source ~/.zshrc</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"> # </span><span class="language-bash">增删改查</span></span><br><span class="line"> nvm install/uninsell/use/list &lt;node-version&gt;</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"> # </span><span class="language-bash">淘宝源</span></span><br><span class="line"> npm install cnpm -g --registry=https://registry.npm.taobao.org</span><br></pre></td></tr></table></figure>

<p>常用 npm 包管理工具</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm cnpm yarn pnpm</span><br></pre></td></tr></table></figure>

<h3 id="配置-pm2"><a href="#配置-pm2" class="headerlink" title="配置 pm2"></a>配置 pm2</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line">cnpm install pm2 -g</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">=================使用</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动某一个node程序</span></span><br><span class="line">pm2 start xxx.js --name=自定义名称</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动ssr项目，npm run start 成功后 ，再执行，也可以直接执行</span></span><br><span class="line">pm2 --name=nuxtName start npm -- run start</span><br><span class="line"></span><br><span class="line">pm2 list   # 查看进程列表</span><br><span class="line">pm2 logs   # 查看日志</span><br><span class="line">pm2 monit  # 监控进程</span><br><span class="line">pm2 show app_name|app_id # 查看进程详细</span><br><span class="line">pm2 stop app_name|app_id|all # 停止进程</span><br><span class="line">pm2 delete app_name|app_id|all # 删除进程</span><br><span class="line">pm2 restart/reload app_name|app_id|all # 重启进程</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动多个程序</span></span><br><span class="line">touch appxx.json</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">写入</span></span><br><span class="line">&#123;</span><br><span class="line">    &quot;app&quot;:[</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;name&quot;:&quot;api&quot;,</span><br><span class="line">            &quot;script&quot;:&quot;server/index.js&quot;, # 找到程序路径</span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            &quot;name&quot;:&quot;node-n&quot;,</span><br><span class="line">            &quot;script&quot;:&quot;client/index.js&quot;, # 找到其他node程序路径</span><br><span class="line">        &#125;,</span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">pm2 start appxx.json</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">=============================设置开机自启</span></span><br><span class="line">pm2 startup</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">保存为开机自启</span></span><br><span class="line">pm2 save</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除pm2 save的操作</span></span><br><span class="line">pm2 unstartup systemd</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">当 node.js 版本更新时，请一定要卸载并新建 自启动脚本</span></span><br><span class="line">pm2 unstartup</span><br><span class="line">pm2 startup</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">恢复上一次保存的自启动列表</span></span><br><span class="line">pm2 resurrect</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">后台运行pm2,启动4个app.js 实现负载均衡</span></span><br><span class="line">pm2 start app.js -i 4</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看端口</span></span><br><span class="line">netstat -lntp</span><br></pre></td></tr></table></figure>

<h3 id="设置-firewall-cmd"><a href="#设置-firewall-cmd" class="headerlink" title="设置 firewall-cmd"></a>设置 firewall-cmd</h3><blockquote>
<p>开启防火墙后远程无法访问服务器的，开放对应端口才能访问 (相当于云服务器的安全组)</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看防火墙状态</span></span><br><span class="line">systemctl status firewalld.servic | service firewalld status | firewall-cmd --state</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">开启防火墙</span></span><br><span class="line">systemctl start firewalld.service | service firewalld start</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">重启防火墙</span></span><br><span class="line">systemctl restart firewalld.service | service firewalld restart | firewall-cmd --reload</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">防火墙开机启动</span></span><br><span class="line">systemctl enable firewalld.service</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">关闭防火墙</span></span><br><span class="line">systemctl stop firewalld.service</span><br></pre></td></tr></table></figure>

<blockquote>
<p>防火墙端口设置（设置完一定要重启防火墙）</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">参数</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">--zone=public 设置区域，默认就是public</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">    public（公共区域）</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">    trusted（信任区域)</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">    ...</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">--permanent 表示设置为持久(写入配置文件中)</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">常见port/service 21/ftp</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通过指令开放端口/服务</span></span><br><span class="line">firewall-cmd --zone=public --add-port=80/tcp --permanent</span><br><span class="line">firewall-cmd --zone=public --add-port=8080-8083/tcp --permanent</span><br><span class="line">firewall-cmd --zone=public --add-service=ssh --permanent</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">配置文件 /etc/firewalld/zones/public.xml zone标签最后一行添加</span></span><br><span class="line">&lt;port protocol=&quot;tcp&quot; port=&quot;80&quot;/&gt;</span><br><span class="line">&lt;port protocol=&quot;tcp&quot; port=&quot;8080-8083&quot;/&gt;</span><br><span class="line">&lt;service name=&quot;ssh&quot;/&gt;</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除/查看端口</span></span><br><span class="line">firewall-cmd --remove-port=80/tcp # 或配置文件直接删除</span><br><span class="line">firewall-cmd --query-port=80/tcp</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">接受来自指定ip的所有请求</span></span><br><span class="line">firewall-cmd --permanent --add-source=xxx.xxx.xxx.xxx --zone=trusted</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">重启</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看开放的端口</span></span><br><span class="line">firewall-cmd --list-all</span><br><span class="line">firewall-cmd --list-ports # 开放的端口</span><br><span class="line">firewall-cmd --list-service # 查看已开通的服务</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<blockquote>
<p>华为云</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">华为云开放端口使可以在页面访问</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1、安全组 Sys-WebServer 添加 端口</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2、防火墙开放端口或关闭防火墙</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">服务器解析第三方域名</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">服务器设置域名解析，添加第三方域名，第三方将域名dns配置设置服务器提供的dns</span></span><br></pre></td></tr></table></figure>

<blockquote>
<p>扩展 iptables</p>
</blockquote>
<h3 id="配置-mysql"><a href="#配置-mysql" class="headerlink" title="配置 mysql"></a>配置 mysql</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下载MySQL安装包 并安装</span></span><br><span class="line">wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm</span><br><span class="line">rpm -ivh mysql57-community-release-el7-8.noarch.rpm</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">跟新秘钥</span></span><br><span class="line">rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">yum 就能找到 mysql-server</span></span><br><span class="line">yum install mysql mysql-server mysql-deve</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动</span></span><br><span class="line">systemctl start/enable mysqld</span><br></pre></td></tr></table></figure>

<h3 id="配置-NFS"><a href="#配置-NFS" class="headerlink" title="配置 NFS"></a>配置 NFS</h3><blockquote>
<p>文件共享（window 上可以访问 linux 系统的共享的目录）</p>
</blockquote>
<p>linux 端</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1、安装 rpcbind、nfs-utils</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2、配置共享文件 /etc/exports</span></span><br><span class="line">/root/nfsshare *(ro)</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">权限规则</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">ro: 可读</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">3、启动服务 rpcbind</span></span><br><span class="line">systemctl start rpcbind</span><br><span class="line">netstat -tunlp|grep 111</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">4、给共享文件夹 /root/nfsshare 添加访问权限</span></span><br><span class="line">chmod -Rf 777 /root/nfsshare # 强制递归给与权限</span><br><span class="line">chown -r nfsnobody:nfsnobody /root/nfsshare</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">5、启动 NFS 服务</span></span><br><span class="line">systemctl start nfs-server.service</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">6、检测本地共享情况</span></span><br><span class="line">showmount -e 127.0.0.1</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">7、检测共享参数</span></span><br><span class="line">cat /var/lib/nfs/etab</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">已经分享成功，后面可以省略</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">8、本地挂载测试</span></span><br><span class="line">mount -t nfs 192.168.203.132:/root/nfsshare /mnt</span><br><span class="line">umount /mnt # 取消挂载</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">9、永久挂载 /etc/fstab</span></span><br><span class="line">192.168.203.132:/root/nfsshare /mnt nfs defaults 0 0</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看挂载情况</span></span><br><span class="line">df -h</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">关闭防火墙，selinux</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">非要开启防火墙</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">找到配置文件 /etc/sysconfig/nfs</span></span><br><span class="line">LOCKD_TCPPORT=32803                                                                                         LOCKD_UDPPORT=32769</span><br><span class="line">MOUNTD_PORT=892</span><br><span class="line">STATD_PORT=662</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">再开启 111、2049 六个端口</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">重启 firewall、nfs-server、rpcbind</span></span><br></pre></td></tr></table></figure>

<p>window 端</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">从 启用或关闭windows功能 勾选 NFS</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看服务器开启的NFS共享</span></span><br><span class="line">showmount -e 192.168.203.132</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">重启电脑 计算机/网络 搜索</span></span><br><span class="line">\\192.168.203.132\root\nfsshare</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将文件夹挂载到window某个目录</span></span><br><span class="line">window 网络右键 &gt; 映射驱动器 &gt; 选择盘符，选择远程地址 \\192.168.203.132\root\nfsshare</span><br></pre></td></tr></table></figure>

<h3 id="配置-cifs-utils"><a href="#配置-cifs-utils" class="headerlink" title="配置 cifs-utils"></a>配置 cifs-utils</h3><blockquote>
<p>将 window 共享的远程文件夹挂载到 linux</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装: cifs-utils</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">共享: window 新建共享文件夹-&gt;高级共享中设置`共享名称` -&gt; 权限给予`读写执行`</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">挂载: mount -t cifs -o username=<span class="string">&quot;Administrator&quot;</span>,password=<span class="string">&quot;1&quot;</span>   //192.168.12.40/nmon /mnt/share</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">     mount -t cifs -o username=<span class="string">&quot;win 用户名&quot;</span>,    password=<span class="string">&quot;密码&quot;</span> //win ip/共享名称     linux挂载目录</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">     <span class="built_in">ls</span> /mnt/share 查看共享文件</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">自动挂载 /etc/fstab</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">//192.168.12.40/nmon /mnt/share cifs defaults,username=名字,password=你的密码</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">//192.168.3.24/共享文件 /mnt/window cifs defaults,username=!·ujcliaozx,password=ujcliaozx123</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">本机案例</span></span><br><span class="line">mount -t cifs -o username=&quot;xun lzo&quot;,password=&quot;lzx123456&quot; //172.22.112.1/lzo-redmi-share /mnt/lzo-redmi-share</span><br></pre></td></tr></table></figure>

<h3 id="配置-cron"><a href="#配置-cron" class="headerlink" title="配置 cron"></a>配置 cron</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">yum install cronie</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">配置文件位置 vim /etc/crontab</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">设置 crontab -e</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看 crontab -l</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">执行记录</span></span><br><span class="line">cat /var/log/cron</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">vimrc 报错，.zshrc 加入</span></span><br><span class="line">export EDITOR=/usr/bin/vim</span><br></pre></td></tr></table></figure>



<h2 id="应用"><a href="#应用" class="headerlink" title="应用"></a>应用</h2><h3 id="安装-autojump"><a href="#安装-autojump" class="headerlink" title="安装 autojump"></a>安装 autojump</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">git clone https://github.com/wting/autojump.git</span><br><span class="line">cd autojump&amp;&amp;./install.py</span><br><span class="line">[[-s ~/.autojump/etc/profile.d/autojump.zsh]] &amp;&amp; . ~/.autojump/etc/profile.d/autojump.zsh  到~/.zshrc</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">缓存数据库位置:`~/.local/shart/autojump/autojump.txt`</span></span><br></pre></td></tr></table></figure>

<h3 id="安装-oh-my-zsh"><a href="#安装-oh-my-zsh" class="headerlink" title="安装 oh-my-zsh"></a>安装 oh-my-zsh</h3><blockquote>
<p>必须 zsh shell 下</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">centos 安装</span></span><br><span class="line">wget https://gitee.com/heyuanfly/install-oh-my-zsh/raw/master/centos-install-oh-my-zsh.sh</span><br><span class="line">chmod +x centos-install-oh-my-zsh.sh</span><br><span class="line">./centos-install-oh-my-zsh.sh</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">使用</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">.zshrc 中 ZSH_THEME=<span class="string">&quot;主题名称&quot;</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">主题都在 `/usr/share/oh-my-zsh/theme`下</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">   推荐主题:`duellj`、`suvash`、`xiong-chiamiov`、`pygmalion`、`fino`、`steeef`、`ys`,`norm`、obraun</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">zsh vi 模式(使用 vim 快捷键)</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">   .zshrc 添加 <span class="built_in">bindkey</span> -v</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">[插件扩展 powerlevel10k](https://github.com/romkatv/powerlevel10k/blob/master/README.md<span class="comment">#oh-my-zsh)</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">   `git <span class="built_in">clone</span> --depth=1 https://gitee.com/romkatv/powerlevel10k.git <span class="variable">$&#123;ZSH_CUSTOM:-<span class="variable">$HOME</span>/.oh-my-zsh/custom&#125;</span>/themes/powerlevel10k`</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">   将 ZSH_THEME=<span class="string">&quot;powerlevel10k/powerlevel10k 设置为 oh-my-zsh主题</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">   `p10k configure`:第一次需要配置，这样重新配置</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">命令行高亮</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">    yay -S zsh-syntax-highlighting zsh-autosuggestions  或 github 下载</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">    如果不生效</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">    sudo ln -s /usr/share/zsh/plugins/zsh-syntax-highlighting /usr/share/oh-my-zsh/custom/plugins/</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="string">    sudo ln -s /usr/share/zsh/plugins/zsh-autosuggestions /usr/share/oh-my-zsh/custom/plugins/  （zsh-autosuggestions 放入.zshrc plugins中）</span></span></span><br></pre></td></tr></table></figure>

<h3 id="安装-lazygit"><a href="#安装-lazygit" class="headerlink" title="安装 lazygit"></a>安装 lazygit</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">先安装 go /docs/server/go/go-bash.md</span></span><br><span class="line"></span><br><span class="line">git clone https://github.com/jesseduffield/lazygit.git</span><br><span class="line">cd lazygit</span><br><span class="line">go install</span><br></pre></td></tr></table></figure>

<h3 id="安装-tig（ing…）"><a href="#安装-tig（ing…）" class="headerlink" title="安装 tig（ing…）"></a>安装 tig（ing…）</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">git 分支数查看</span></span><br><span class="line">yum install tig</span><br></pre></td></tr></table></figure>



<h3 id="安装-ranger"><a href="#安装-ranger" class="headerlink" title="安装 ranger"></a>安装 ranger</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装python3和pip3</span></span><br><span class="line">yum install python3 python3-devel -y</span><br><span class="line">pip3 install ranger-fm -i https://mirrors.aliyun.com/pypi/simple/</span><br></pre></td></tr></table></figure>

<h4 id="配置-1"><a href="#配置-1" class="headerlink" title="配置"></a>配置</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">1、</span></span><br><span class="line">ranger --copy-config=all</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">2、</span></span><br><span class="line">~/.config/ranger</span><br><span class="line">    rc.conf-选项设置和快捷键</span><br><span class="line">    commands.py-能通过:执行的命令</span><br><span class="line">    commands_full.py-全套命令</span><br><span class="line">    rifle.conf-指定不同类型的文件的默认打开程序</span><br><span class="line">    scope.conf-负责各种文件预览</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">3、</span></span><br><span class="line">echo &quot;export RANGER_LOAD_DEFAULT_RC=false&quot;&gt;&gt;~/.zshrc</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">4、操作</span></span><br><span class="line">修改配置文件~/.config/ranger/rc.conf</span><br><span class="line">显示边框set draw_borders both</span><br><span class="line">显示序号set line_numbers true</span><br><span class="line">序号从1开始set one_indexed true</span><br></pre></td></tr></table></figure>

<h4 id="插件"><a href="#插件" class="headerlink" title="插件"></a>插件</h4><blockquote>
<p>图标</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">myfork https://hub.fgit.ml/liaozhongxun/ranger_devicons.git</span></span><br><span class="line">git clone https://github.com/alexanderjeurissen/ranger_devicons ~/.config/ranger/plugins/ranger_devicons</span><br><span class="line">echo &quot;default_linemode devicons&quot; &gt;&gt; $HOME/.config/ranger/rc.conf</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">乱码 https://github.com/ryanoasis/nerd-fonts</span></span><br></pre></td></tr></table></figure>

<blockquote>
<p>压缩包预览</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install atool</span><br></pre></td></tr></table></figure>



<h3 id="安装-tmux"><a href="#安装-tmux" class="headerlink" title="安装 tmux"></a>安装 tmux</h3><p>安装 libevent</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz</span><br><span class="line">tar -zxvf libevent-2.1.12-stable.tar.gz</span><br><span class="line">cd libevent-2.1.12-stable</span><br><span class="line">./configure --disable-openssl</span><br><span class="line">make &amp;&amp; make install</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">如果有报错</span></span><br><span class="line">sudo ln -s /usr/local/lib/libevent-2.1.so.7 /usr/lib64/</span><br></pre></td></tr></table></figure>

<p>安装 tmux</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git clone https://github.com/tmux/tmux.git</span><br><span class="line">cd tmux</span><br><span class="line">sh autogen.sh</span><br><span class="line">./configure &amp;&amp; make</span><br></pre></td></tr></table></figure>

<p>异常</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">error while loading shared libraries: libevent_core-2.1.so.7: cannot open shared object file: No such file or directory</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">程序无法找到libevent-2.1.so.7这个动态库</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">添加配置到 ld.so.conf 文件中</span></span><br><span class="line">sudo echo &quot;/usr/local/lib&quot; &gt;&gt; /etc/ld.so.conf</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">跟新配置</span></span><br><span class="line">sudo ldconfig</span><br><span class="line"></span><br><span class="line">tmux new -s tm</span><br></pre></td></tr></table></figure>

<p>主题包</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">https://blog.csdn.net/Arise_/article/details/127085812</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">主题包 oh-my-tmux</span></span><br><span class="line">cd ~</span><br><span class="line">git clone https://github.com/gpakosz/.tmux.git</span><br><span class="line">ln -s -f .tmux/.tmux.conf  #创建软连接</span><br><span class="line">cp .tmux/.tmux.conf.local . #复制local文件到当前文件夹 可以覆盖默认配置</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">tmux source-file ~/.tmux.conf  从新加载配置</span></span><br></pre></td></tr></table></figure>

<h3 id="安装-vim"><a href="#安装-vim" class="headerlink" title="安装 vim"></a>安装 vim</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">vim 包管理工具 vimplus</span></span><br><span class="line">git clone https://github.com/chxuan/vimplus.git ~/.vimplus</span><br><span class="line">cd ~/.vimplus</span><br><span class="line">./install.sh</span><br><span class="line">./update.sh # 更新</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装插件</span></span><br><span class="line">:PlugInstall</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">插件位置</span></span><br><span class="line">~/.vim/plugged</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">基本配置</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">`~/.vimrc为vimplus`的默认配置，一般不做修改</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">`~/.vimrc.custom.plugins`为用户自定义插件列表，用户增加、卸载插件请修改该文件</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">`~/.vimrc.custom.config`为用户自定义配置文件，一般性配置请放入该文件，可覆盖~/.vimrc 里的配置</span></span><br></pre></td></tr></table></figure>

<h3 id="安装-fzf"><a href="#安装-fzf" class="headerlink" title="安装 fzf"></a>安装 fzf</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf</span><br><span class="line">~/.fzf/install</span><br><span class="line"></span><br><span class="line">npmc install -g fd-find</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">fd 缺少 glibc-2.18</span></span><br><span class="line">curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz</span><br><span class="line">tar zxf glibc-2.18.tar.gz</span><br><span class="line">cd glibc-2.18/</span><br><span class="line">mkdir build</span><br><span class="line">cd build/</span><br><span class="line">../configure --prefix=/usr</span><br><span class="line">make -j2</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>

<p>高亮搜索</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">~/.zshrc</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">界面展示这些参数在 fzf --<span class="built_in">help</span> 中都有，按需配置即可 highlight 预览高亮可能需要安装</span></span><br><span class="line">export FZF_DEFAULT_OPTS=&quot;--border --preview &#x27;(highlight -O ansi &#123;&#125; || cat &#123;&#125;) 3&gt; /dev/null | head -500&#x27;&quot;</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">fzf查找配安装 fd-find (可搜索隐藏文件)</span></span><br><span class="line">export FZF_DEFAULT_COMMAND=&quot;fd --exclude=&#123;.git,.idea,.vscode,.sass-cache,node_modules,build&#125; --type f --hidden&quot;</span><br></pre></td></tr></table></figure>

<h3 id="安装-htop"><a href="#安装-htop" class="headerlink" title="安装 htop"></a>安装 htop</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通过上下左右控制，不能HJKL</span></span><br><span class="line">-   `F1`:帮助</span><br><span class="line">-	`F2`:设置</span><br><span class="line">-   `F3`:搜索</span><br><span class="line">-   `F4`:过滤(隐藏不匹配的进程)</span><br><span class="line">-   `F5`:进程树</span><br><span class="line">-	`F6`:排序</span><br><span class="line">-   `F9`:杀死选中的进程</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">快捷键</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">u         选择用户，查看指定用户相关的进程</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">shift</span>+p   按CPU占用大小排序</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">shift</span>+m   按占用内存大小排序</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">shift</span>+i   反转排序</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">空格       标记进程，批量操作</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="安装-SHC"><a href="#安装-SHC" class="headerlink" title="安装 SHC"></a>安装 SHC</h3><blockquote>
<p>加密工具</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">将脚本加密，同意可以运行，打开查看的缺少密文</span></span><br><span class="line">yum install shc</span><br><span class="line"></span><br><span class="line">shc -f test.sh # 成功后生成 test.sh.x ,可执行的密文</span><br></pre></td></tr></table></figure>



<h3 id="安装-screenFetch"><a href="#安装-screenFetch" class="headerlink" title="安装 screenFetch"></a>安装 screenFetch</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">CentOS screenfetch</span><br><span class="line">cd /usr/local/src</span><br><span class="line">git clone https://github.com/liaozhongxun/screenFetch.git</span><br><span class="line">cp screenFetch/screenfetch-dev /usr/local/bin/screenfetch</span><br><span class="line">chmod 755 /usr/local/bin/screenfetch</span><br></pre></td></tr></table></figure>

<h2 id="指令"><a href="#指令" class="headerlink" title="指令"></a>指令</h2><h3 id="磁盘占用"><a href="#磁盘占用" class="headerlink" title="磁盘占用"></a>磁盘占用</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">df -h # 人性化显示大小</span><br><span class="line">df -T # 查看文件系统格式</span><br></pre></td></tr></table></figure>

<h3 id="文件大小"><a href="#文件大小" class="headerlink" title="文件大小"></a>文件大小</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">du -h # 人性化显示</span><br><span class="line">du -s # 汇总，查看目录所有文件占用磁盘空间</span><br></pre></td></tr></table></figure>

<h3 id="压缩包"><a href="#压缩包" class="headerlink" title="压缩包"></a>压缩包</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">tar 压缩</span></span><br><span class="line">tar -zcvf fileName.tar /root/dist # -z 打包方式 gzip，-c 打包，-v 列出详情 -f 新文件名</span><br><span class="line">tar -xf fileName.tar -C /target_dir # -x 解包，-f 解压的文件</span><br><span class="line">tar -tf fileName.tar.gz # 不解包直接查看压缩包内容</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">zip 将 /root/dist 压缩为 fileName.zip</span></span><br><span class="line">zip -q -r fileName.zip /root/dist # -r 递归处理文件夹 -q 不显示执行过程</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">zip 从 fileName.zip 压缩 删除 index.html 文件</span></span><br><span class="line">zip -dv fileName.zip index.html # -d 从压缩文件内删除指定文件</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">解压 unzip</span></span><br><span class="line">unzip fileName.zip</span><br><span class="line">unzip fileName.zip -d /home/xxx # -d 解压文件到当指定目录，-n 不覆盖原有文件,-o 覆盖</span><br><span class="line">unzip -v fileName.zip # 查看信息不解压</span><br></pre></td></tr></table></figure>

<h2 id="功能"><a href="#功能" class="headerlink" title="功能"></a>功能</h2><h3 id="文件锁"><a href="#文件锁" class="headerlink" title="文件锁"></a>文件锁</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">保存文件时 :X</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">输入两次密码</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">:wq 退出</span></span><br></pre></td></tr></table></figure>

<h3 id="文件操作"><a href="#文件操作" class="headerlink" title="文件操作"></a>文件操作</h3><blockquote>
<p>删除指定文件外的所有</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">find * | grep -v 1.txt | xargs rm</span><br><span class="line">find * | grep -v &#x27;\(1.txt\|2.txt\)&#x27; | xargs rm</span><br></pre></td></tr></table></figure>

<blockquote>
<p>替换指定目录下，所有文件的指定内容</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sed -i &quot;s#https#http#g&quot; `grep http -rl VERO` # 将 VERO 下所有子目录所有文件里的 http 替换成 https</span><br><span class="line">sed -i &quot;s#456#789#g&quot; `grep 456 -rl ./lianxi` # 将 lianxi 下所有子目录所有文件里的 456 替换成 789</span><br></pre></td></tr></table></figure>

<blockquote>
<p>查询存在指定内容的文件</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">grep 456 -rl ./lianxi # 找到 lianxi 下所有存在 456 的文件</span><br></pre></td></tr></table></figure>

<blockquote>
<p>查询存在指定内容的文件并打印</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">grep 456 -r ./lianxi</span><br><span class="line"></span><br><span class="line">grep -2 -r &#x27;456&#x27; ./     # 输出查找内容前后五行</span><br><span class="line">grep -A 2 -r &#x27;456&#x27; ./   # 输出查找内容后五行</span><br><span class="line">grep -B 2 -r &#x27;456&#x27; ./   # 输出查找内容前五行</span><br></pre></td></tr></table></figure>

<h3 id="通过端口查数据"><a href="#通过端口查数据" class="headerlink" title="通过端口查数据"></a>通过端口查数据</h3><blockquote>
<p>通过端口，查看占用的程序名称</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">有 pid进程号/程序名</span></span><br><span class="line">netstat -anp | grep 3306</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">有程序名、pid进程号</span></span><br><span class="line">lsof -i :3306</span><br></pre></td></tr></table></figure>

<h3 id="通过-PID-查数据"><a href="#通过-PID-查数据" class="headerlink" title="通过 PID 查数据"></a>通过 PID 查数据</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netstat -antup|grep pid</span><br></pre></td></tr></table></figure>

<h3 id="通过进程名查数据"><a href="#通过进程名查数据" class="headerlink" title="通过进程名查数据"></a>通过进程名查数据</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netstat -antup|grep nginx</span><br></pre></td></tr></table></figure>

<h3 id="查看进程关联的文件"><a href="#查看进程关联的文件" class="headerlink" title="查看进程关联的文件"></a>查看进程关联的文件</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">lsof -c Pid # 打印指定进程使用到的文件</span><br></pre></td></tr></table></figure>

<h3 id="通过域名查-IP"><a href="#通过域名查-IP" class="headerlink" title="通过域名查 IP"></a>通过域名查 IP</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nslookup github.com</span><br></pre></td></tr></table></figure>

<h3 id="统计文件行数"><a href="#统计文件行数" class="headerlink" title="统计文件行数"></a>统计文件行数</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">grep 找到当前文件夹下所有文件 | 排除不需要统计的目录或文件 | 输出所有文件空行取反 | 查看内容行数</span></span><br><span class="line">grep . -rl --exclude-dir=&#123;node_modules,dist&#125; --exclude=&#123;yarn.lock&#125; ./|xargs grep -v &quot;^$&quot;|wc -l</span><br></pre></td></tr></table></figure>

<h3 id="排除某个文件的批量操作"><a href="#排除某个文件的批量操作" class="headerlink" title="排除某个文件的批量操作"></a>排除某个文件的批量操作</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">复制单前目录下除了bak文件夹的其他所有文件到 bak目录</span></span><br><span class="line">ls | grep -v bak | xargs -i cp -r &#123;&#125; bak/</span><br></pre></td></tr></table></figure>



<h3 id="通配符"><a href="#通配符" class="headerlink" title="通配符"></a>通配符</h3><blockquote>
<p> 适用于匹配文件<strong>名</strong>的操作</p>
</blockquote>
<table>
<thead>
<tr>
<th>字符</th>
<th align="center">通配符</th>
<th>正则</th>
<th>同效</th>
</tr>
</thead>
<tbody><tr>
<td>*</td>
<td align="center">匹配任意数量（包括0个字符） 如：ls *.txt (列出所有以.txt结尾的文件)</td>
<td>前面分组0或多个</td>
<td>.*</td>
</tr>
<tr>
<td>?</td>
<td align="center">匹配单个字符  如： ls ?.txt   (1.txt&#x2F;a.txt&#x2F;n.txt)</td>
<td>前面分组可有可无</td>
<td>.</td>
</tr>
<tr>
<td>[]</td>
<td align="center">匹配括号内给定的任何一个字符 如：ls [abc].txt</td>
<td>相同</td>
<td>[]</td>
</tr>
<tr>
<td>{}</td>
<td align="center">指定可选项集合 如：cp file{1,2}.txt dir (将file1.txt 和file2.txt 放入dir目录中)</td>
<td>前面分组个数限定</td>
<td>|</td>
</tr>
</tbody></table>
<h3 id="正则"><a href="#正则" class="headerlink" title="正则"></a>正则</h3><blockquote>
<p>适用于匹配文件<strong>内容</strong>的操作</p>
</blockquote>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="查看系统信息"><a href="#查看系统信息" class="headerlink" title="查看系统信息"></a>查看系统信息</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通过lsb</span></span><br><span class="line">yum install -y redhat-lsb-core</span><br><span class="line">lsb_release -a</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通过 screenfetch</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通过 top/htop</span></span><br></pre></td></tr></table></figure>

<h3 id="运行级别"><a href="#运行级别" class="headerlink" title="运行级别"></a>运行级别</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">ls -la /usr/lib/systemd/system|grep runlevel</span><br><span class="line"></span><br><span class="line"> -   <span class="string">`runlevel0.target`</span>: poweroff.<span class="title function_">target</span>(<span class="string">`不运行服务 关机`</span>)</span><br><span class="line"> -   <span class="string">`runlevel1.target`</span>: resuce.<span class="title function_">target</span>(<span class="string">`救援|单例|安全模式`</span>)</span><br><span class="line"> -   <span class="string">`runlevel2.target`</span>: multi-user.<span class="property">target</span></span><br><span class="line"> -   <span class="string">`runlevel3.target`</span>: multi-user.<span class="property">target</span></span><br><span class="line"> -   <span class="string">`runlevel4.target`</span>: multi-user.<span class="title function_">target</span>(<span class="string">`2，3，4多用户模式`</span>，不运行图形界面级相关服务，字符界面)</span><br><span class="line"> -   <span class="string">`runlevel5.target`</span>: graphical.<span class="title function_">target</span>(<span class="string">`图形相关服务`</span>)</span><br><span class="line"> -   <span class="string">`runlevel6.target`</span>: reboot.<span class="title function_">target</span>(<span class="string">`重启`</span>)</span><br><span class="line"></span><br><span class="line">systemctl get-<span class="keyword">default</span>   <span class="comment">// 查看默认运行级别</span></span><br><span class="line">systemctl set-<span class="keyword">default</span> multi-user.<span class="property">target</span></span><br><span class="line">runlevel <span class="comment">// 查看单前级别</span></span><br><span class="line">init n <span class="comment">// 临时切换运行级别</span></span><br></pre></td></tr></table></figure>

<h3 id="文件查找"><a href="#文件查找" class="headerlink" title="文件查找"></a>文件查找</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"> - 通过扩展名查找文件：</span><br><span class="line">   find 指定目录 -name <span class="string">&#x27;*.ext&#x27;</span></span><br><span class="line"></span><br><span class="line"> - 查找匹配多个路径或名称模式的文件：</span><br><span class="line">   find 指定目录 -path <span class="string">&#x27;**/path/**/*.ext&#x27;</span> -or -name <span class="string">&#x27;*pattern*&#x27;</span></span><br><span class="line"></span><br><span class="line"> - 查找匹配指定名称的目录，不区分大小写：</span><br><span class="line">   find 指定目录 -type d -iname <span class="string">&#x27;*lib*&#x27;</span></span><br><span class="line"></span><br><span class="line"> - 查找匹配指定模式的文件，排除特定路径：</span><br><span class="line">   find 指定目录 -name <span class="string">&#x27;*.py&#x27;</span> -not -path <span class="string">&#x27;*/site-packages/*&#x27;</span></span><br><span class="line"></span><br><span class="line"> - 查找符合指定大小范围的文件：</span><br><span class="line">   find 指定目录 -size +500k -size -10M</span><br><span class="line"></span><br><span class="line"> - 对每个文件运行命令（在命令中使用 <span class="string">`&#123;&#125;`</span> 代表当前文件）：</span><br><span class="line">   find 指定目录 -name <span class="string">&#x27;*.ext&#x27;</span> -exec wc -l &#123;&#125; \;</span><br><span class="line"></span><br><span class="line"> - 查找最近 <span class="number">7</span> 天修改的文件并删除：</span><br><span class="line">   find 指定目录 -daystart -mtime -<span class="number">7</span> -<span class="keyword">delete</span></span><br><span class="line"></span><br><span class="line"> - 查找空（<span class="number">0</span> 字节）的文件并删除：</span><br><span class="line">   find 指定目录 -type f -empty -<span class="keyword">delete</span></span><br><span class="line">   </span><br><span class="line"> -- 找到指定文件夹下所有文件进行操作</span><br><span class="line">find 指定目录 <span class="string">&quot;.*&quot;</span> -exec chown <span class="attr">lzoxun</span>:lzoxun &#123;&#125; \; </span><br></pre></td></tr></table></figure>



<h2 id="工具"><a href="#工具" class="headerlink" title="工具"></a>工具</h2><h3 id="nikto"><a href="#nikto" class="headerlink" title="nikto"></a>nikto</h3><blockquote>
<p>网站检测</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nikto -h www.lzoxun.top</span><br></pre></td></tr></table></figure>

<p><img src= "" data-lazy-src="/../../static/img/2023-07-22_003615.jpg"></p>
<h3 id="lrzsz"><a href="#lrzsz" class="headerlink" title="lrzsz"></a>lrzsz</h3><blockquote>
<p>用上传下载的 SSH 连接工具，终端直连无效</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">dnf install lrzsz</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">上传</span></span><br><span class="line">rz</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下载</span></span><br><span class="line">sz &lt;file-name&gt;</span><br></pre></td></tr></table></figure>

<h3 id="ncdu"><a href="#ncdu" class="headerlink" title="ncdu"></a>ncdu</h3><blockquote>
<p>树结构统计文件大小，du 指令优化</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">- c # 显示目录子目录文件总数</span><br><span class="line">- d # 删除文件</span><br><span class="line">- e # 隐藏文件显示</span><br><span class="line">- g # 百分比</span><br><span class="line">- h/j/k/l # 上级/向下/向上/下级</span><br><span class="line">- i # 显示文件相关信息</span><br><span class="line">- r # 刷新</span><br></pre></td></tr></table></figure>



<h3 id="tldr"><a href="#tldr" class="headerlink" title="tldr"></a>tldr</h3><blockquote>
<p>简洁文档</p>
</blockquote>
<h3 id="cloc"><a href="#cloc" class="headerlink" title="cloc"></a>cloc</h3><blockquote>
<p>文件数(files)、空白行数(blank)、注释行数(comment)和代码行数(code)</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cloc ./dist</span><br></pre></td></tr></table></figure>

<h3 id="asciinema"><a href="#asciinema" class="headerlink" title="asciinema"></a>asciinema</h3><blockquote>
<p>终端下非常棒的录屏和回放软件</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">录制</span></span><br><span class="line">asciinema rec</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">结束录制</span></span><br><span class="line">ctrl+d 或 exit</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Enter 上传，生成地址</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Ctrl+c 取消</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">播放</span></span><br><span class="line">asciinema play https://asciinema.org/a/aJ8I9rH4Ob5wbNAywiskRu0cz</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="包下载器"><a href="#包下载器" class="headerlink" title="包下载器"></a>包下载器</h3><p><code>yum</code>、 <code>pip3</code>、<code>dnf</code>、<code>wget</code>、<code>curl</code></p>
<h3 id="连接工具"><a href="#连接工具" class="headerlink" title="连接工具"></a>连接工具</h3><p><a target="_blank" rel="noopener" href="https://mobaxterm.mobatek.net/">MobaXterm</a> <a target="_blank" rel="noopener" href="http://www.hostbuf.com/t/988.html">FinalShell</a> <a target="_blank" rel="noopener" href="https://github.com/kingToolbox/WindTerm/releases">WindTerm</a></p>
<h2 id="个人配置"><a href="#个人配置" class="headerlink" title="个人配置"></a>个人配置</h2><h3 id="linux-alias"><a href="#linux-alias" class="headerlink" title="linux alias"></a>linux alias</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">alias jsr=&quot;systemctl restart&quot;</span><br><span class="line">alias jss=&quot;systemctl start&quot;</span><br><span class="line">alias jst=&quot;systemctl stop&quot;</span><br><span class="line">alias jse=&quot;systemctl enable&quot;</span><br><span class="line"></span><br><span class="line">alias tm=&quot;tmux new -t tm&quot;</span><br><span class="line"></span><br><span class="line">alias lg=&quot;lazygit&quot;</span><br><span class="line">alias ll=&#x27;ls -la&#x27;</span><br><span class="line">alias n=&#x27;npm run dev&#x27;</span><br><span class="line">alias nse=&#x27;npm run serve&#x27;</span><br><span class="line">alias nst=&#x27;npm run start&#x27;</span><br><span class="line">alias nb=&#x27;npm run build&#x27;</span><br><span class="line"></span><br><span class="line">alias gs=&#x27;git status&#x27;</span><br><span class="line">alias ga=&#x27;git add .&#x27;</span><br><span class="line">alias gcm=&#x27;git commit -m&#x27;</span><br><span class="line">alias gph=&#x27;git push origin&#x27;</span><br><span class="line">alias gpl=&#x27;git pull origin&#x27;</span><br><span class="line">alias gl=&#x27;git log&#x27;</span><br><span class="line">alias gb=&#x27;git branch&#x27;</span><br><span class="line">alias gc=&#x27;git checkout&#x27;</span><br><span class="line">bindkey -v</span><br></pre></td></tr></table></figure>

<h3 id="window-alias"><a href="#window-alias" class="headerlink" title="window alias"></a>window alias</h3></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://example.com">lzoxun</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2023/07/22/linux/linux-centos/">http://example.com/2023/07/22/linux/linux-centos/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">学习笔记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/07/22/linux/linux-archlinux/" title="archlinux"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">archlinux</div></div></a></div><div class="next-post pull-right"><a href="/2023/07/22/linux/linux-kali/" title="kali"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">kali</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">lzoxun</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/liaozhongxun"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/liaozhongxun" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:869664233@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">这是我的文档</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">1.</span> <span class="toc-text">安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE"><span class="toc-number">2.</span> <span class="toc-text">配置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BD%91%E7%BB%9C%E9%85%8D%E7%BD%AE"><span class="toc-number">2.1.</span> <span class="toc-text">网络配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-yum-dnf"><span class="toc-number">2.2.</span> <span class="toc-text">配置 yum &#x2F; dnf</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-git"><span class="toc-number">2.3.</span> <span class="toc-text">配置 git</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-nginx"><span class="toc-number">2.4.</span> <span class="toc-text">配置 nginx</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-zsh"><span class="toc-number">2.5.</span> <span class="toc-text">配置 zsh</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-ssh"><span class="toc-number">2.6.</span> <span class="toc-text">配置 ssh</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-nvm"><span class="toc-number">2.7.</span> <span class="toc-text">配置 nvm</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-pm2"><span class="toc-number">2.8.</span> <span class="toc-text">配置 pm2</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE-firewall-cmd"><span class="toc-number">2.9.</span> <span class="toc-text">设置 firewall-cmd</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-mysql"><span class="toc-number">2.10.</span> <span class="toc-text">配置 mysql</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-NFS"><span class="toc-number">2.11.</span> <span class="toc-text">配置 NFS</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-cifs-utils"><span class="toc-number">2.12.</span> <span class="toc-text">配置 cifs-utils</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-cron"><span class="toc-number">2.13.</span> <span class="toc-text">配置 cron</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BA%94%E7%94%A8"><span class="toc-number">3.</span> <span class="toc-text">应用</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-autojump"><span class="toc-number">3.1.</span> <span class="toc-text">安装 autojump</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-oh-my-zsh"><span class="toc-number">3.2.</span> <span class="toc-text">安装 oh-my-zsh</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-lazygit"><span class="toc-number">3.3.</span> <span class="toc-text">安装 lazygit</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-tig%EF%BC%88ing%E2%80%A6%EF%BC%89"><span class="toc-number">3.4.</span> <span class="toc-text">安装 tig（ing…）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-ranger"><span class="toc-number">3.5.</span> <span class="toc-text">安装 ranger</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-1"><span class="toc-number">3.5.1.</span> <span class="toc-text">配置</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%8F%92%E4%BB%B6"><span class="toc-number">3.5.2.</span> <span class="toc-text">插件</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-tmux"><span class="toc-number">3.6.</span> <span class="toc-text">安装 tmux</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-vim"><span class="toc-number">3.7.</span> <span class="toc-text">安装 vim</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-fzf"><span class="toc-number">3.8.</span> <span class="toc-text">安装 fzf</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-htop"><span class="toc-number">3.9.</span> <span class="toc-text">安装 htop</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-SHC"><span class="toc-number">3.10.</span> <span class="toc-text">安装 SHC</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-screenFetch"><span class="toc-number">3.11.</span> <span class="toc-text">安装 screenFetch</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8C%87%E4%BB%A4"><span class="toc-number">4.</span> <span class="toc-text">指令</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%A3%81%E7%9B%98%E5%8D%A0%E7%94%A8"><span class="toc-number">4.1.</span> <span class="toc-text">磁盘占用</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E5%A4%A7%E5%B0%8F"><span class="toc-number">4.2.</span> <span class="toc-text">文件大小</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8E%8B%E7%BC%A9%E5%8C%85"><span class="toc-number">4.3.</span> <span class="toc-text">压缩包</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8A%9F%E8%83%BD"><span class="toc-number">5.</span> <span class="toc-text">功能</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E9%94%81"><span class="toc-number">5.1.</span> <span class="toc-text">文件锁</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C"><span class="toc-number">5.2.</span> <span class="toc-text">文件操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E8%BF%87%E7%AB%AF%E5%8F%A3%E6%9F%A5%E6%95%B0%E6%8D%AE"><span class="toc-number">5.3.</span> <span class="toc-text">通过端口查数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E8%BF%87-PID-%E6%9F%A5%E6%95%B0%E6%8D%AE"><span class="toc-number">5.4.</span> <span class="toc-text">通过 PID 查数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E8%BF%87%E8%BF%9B%E7%A8%8B%E5%90%8D%E6%9F%A5%E6%95%B0%E6%8D%AE"><span class="toc-number">5.5.</span> <span class="toc-text">通过进程名查数据</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E8%BF%9B%E7%A8%8B%E5%85%B3%E8%81%94%E7%9A%84%E6%96%87%E4%BB%B6"><span class="toc-number">5.6.</span> <span class="toc-text">查看进程关联的文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E8%BF%87%E5%9F%9F%E5%90%8D%E6%9F%A5-IP"><span class="toc-number">5.7.</span> <span class="toc-text">通过域名查 IP</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BB%9F%E8%AE%A1%E6%96%87%E4%BB%B6%E8%A1%8C%E6%95%B0"><span class="toc-number">5.8.</span> <span class="toc-text">统计文件行数</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8E%92%E9%99%A4%E6%9F%90%E4%B8%AA%E6%96%87%E4%BB%B6%E7%9A%84%E6%89%B9%E9%87%8F%E6%93%8D%E4%BD%9C"><span class="toc-number">5.9.</span> <span class="toc-text">排除某个文件的批量操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E9%85%8D%E7%AC%A6"><span class="toc-number">5.10.</span> <span class="toc-text">通配符</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%AD%A3%E5%88%99"><span class="toc-number">5.11.</span> <span class="toc-text">正则</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF"><span class="toc-number">5.12.</span> <span class="toc-text">查看系统信息</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%90%E8%A1%8C%E7%BA%A7%E5%88%AB"><span class="toc-number">5.13.</span> <span class="toc-text">运行级别</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E6%9F%A5%E6%89%BE"><span class="toc-number">5.14.</span> <span class="toc-text">文件查找</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B7%A5%E5%85%B7"><span class="toc-number">6.</span> <span class="toc-text">工具</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#nikto"><span class="toc-number">6.1.</span> <span class="toc-text">nikto</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#lrzsz"><span class="toc-number">6.2.</span> <span class="toc-text">lrzsz</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#ncdu"><span class="toc-number">6.3.</span> <span class="toc-text">ncdu</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tldr"><span class="toc-number">6.4.</span> <span class="toc-text">tldr</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#cloc"><span class="toc-number">6.5.</span> <span class="toc-text">cloc</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#asciinema"><span class="toc-number">6.6.</span> <span class="toc-text">asciinema</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8C%85%E4%B8%8B%E8%BD%BD%E5%99%A8"><span class="toc-number">6.7.</span> <span class="toc-text">包下载器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%9E%E6%8E%A5%E5%B7%A5%E5%85%B7"><span class="toc-number">6.8.</span> <span class="toc-text">连接工具</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%AA%E4%BA%BA%E9%85%8D%E7%BD%AE"><span class="toc-number">7.</span> <span class="toc-text">个人配置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#linux-alias"><span class="toc-number">7.1.</span> <span class="toc-text">linux alias</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#window-alias"><span class="toc-number">7.2.</span> <span class="toc-text">window alias</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-11/" title="win 11 set">win 11 set</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-gitbash/" title="git bash">git bash</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-wsl/" title="wsl">wsl</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-main/" title="window">window</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/web/%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98/" title="兼容问题">兼容问题</a><time datetime="2023-07-22T07:14:09.699Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By lzoxun</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><div class="js-pjax"></div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div class="no-result" id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/haruto.model.json"},"display":{"position":"right","width":100,"height":200,"right":300},"mobile":{"show":true}});</script></body></html>